<%@page pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

	<!--
		Supersized - Fullscreen Slideshow jQuery Plugin
		Version : 3.2.7
		Site	: www.buildinternet.com/project/supersized
		
		Author	: Sam Dunn
		Company : One Mighty Roar (www.onemightyroar.com)
		License : MIT License / GPL License
	-->

	<head>
		<%@include file="/coframe/tools/skins/common.jsp" %>
		<title></title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

		
	</head>
	<style>
	.container{
		width:100%;
		display:flex;
	}
	.container-i{
		flex:1
	}
	.panel{
		margin:10px;
		border-radius:10px;
		background:#f8f8f8;
		overflow:hidden;
		box-shadow:5px 5px 15px #ccc
	}
	.panel-header{
		background:rgb(234,219,216);
		padding:10px;
		font-size:16px;
		color:#333
	}
	.panel-body{
		padding:10px;
		color:#666
	}
	.panel-footer{
		padding:10px;
		text-align:right;
		font-size:12px;
		color:#999
	}
	.container-i:nth-of-type(2n) .panel:nth-of-type(2n+1) .panel-header{
		background:rgba(234,219,216,0.5);
	}
	.panel:nth-of-type(2n) .panel-header{
		background:rgba(234,219,216,0.5);
	}
	
	.log-i:not(:last-child){
		margin-bottom:10px;
		border-bottom:1px dashed rgba(0,0,0,0.1)
	}
	.log-i .time{
		font-size:12px;
		color:#999;
		text-align:right
	}
	.log-i .name{
		font-size:14px;
		ling-height:25px;
		color:#333;
	}
	.log-i .content{
		font-size:12px;
		color:#666;
		padding:10px 20px;
	}
	</style>

<body>

	<div class="container">
		<div class="container-i">
			<div class="panel">
				<div class="panel-header">数据报告 <i style="float:right; color:blue; cursor: pointer;" onclick="refresh('data')">刷新</i></div>
				<div class="panel-body" >
					BUG总数    :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<span style="font-size:40px;" id="countbug"></span>
					   个
					   <br/><br/>
					   项目总数    :&nbsp;&nbsp;
					<span style="font-size:40px;" id="countproject">10</span>
					   个
					   <br/><br/>
					   进行中项目总数    :&nbsp;&nbsp;
					<span style="font-size:40px;" id="countJxproject">10</span>
					   个
				</div>

			</div>
			<div class="panel">
				<div class="panel-header">项目进度 <i style="float:right; color:blue; cursor: pointer;" onclick="refresh('proList')">刷新</i></div>
				<div class="panel-body" id="project">
	
				</div>
				<div class="panel-footer">
					<a href="/xmgl/xmgl/ZhmyProjectList.jsp">查看更多>></a>
				</div>
			</div>
		</div>
		<div class="container-i">
			<div class="panel">
				<div class="panel-header">最新消息 <i style="float:right; color:blue; cursor: pointer;" onclick="refresh('logList')">刷新</i></div>
				<div class="panel-body" id="log">
					日志内容
				</div>
				<div class="panel-footer">
					<a href="/xmgl/xmgl/ZhmyLogList.jsp">查看更多>></a>
				</div>
			</div>
		</div>
		<div class="container-i">
			<div class="panel">
				<div class="panel-header">Bug列表 <i style="float:right; color:blue; cursor: pointer;" onclick="refresh('bugList')">刷新</i></div>
				<div class="panel-body" id="buglist" >bug列表</div>
				<div class="panel-footer">
					<a href="/xmgl/xmgl/ZhmyBugList.jsp">查看更多>></a>
				</div>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
    	nui.parse();
        function beautySub(str, len) {
		    var reg = /[\u4e00-\u9fa5]/g,    //专业匹配中文
		        slice = str.substring(0, len),
		        chineseCharNum = (~~(slice.match(reg) && slice.match(reg).length)),
		        realen = slice.length*2 - chineseCharNum;
		    return str.substr(0, realen) + (realen < str.length ? "..." : "");
		}
        var json = "";
		var projectDict = {};
		function getLogList(){
		
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmylogbiz.queryZhmyLogsForWelcome.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	                	returnJson = returnJson['zhmylogs']
	                	
	                	var str = '';
	                	for(var i = 0;i < returnJson.length;i++){
	                		if(i > 5){
	                		return false;
	                		}else{
		                		str += '<div class="log-i">';
		                		    str += '<p class="name">【所属项目】'+ returnJson[i]['zhmyProject']['projectName'] +'</p>';
		                			str += '<p class="name">【日志】' + returnJson[i]['logTitle'] +'</p>';
		                			str += '<p class="content">' + beautySub(returnJson[i]['logContent'],50)+ '</p>';
		                			str += '<p class="time">' + returnJson[i]['ctime']+ '</p>';
		                		str += '</div>';
	                		}
	                	}
	  					document.getElementById('log').innerHTML = str
	                	
	                   // CloseWindow("saveSuccess");
	                }else{
	                    nui.alert("没有找到此任务", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
	                }
	            }
	   		 });
   		 }
		getLogList();
		function getProjectDict() {
			$.ajax({
				url:"<%=request.getContextPath() %>/xmgl/com.primeton.components.nui.DictLoader.getDictData.biz.ext",
				type:"post",
				data:{
					dictTypeId:"PROJECT_PROGRESS"
				},
				success: function(response) {
					projectDict = {};
					for (var j = 0; j < response.dictList.length; j++) {
                		projectDict["dict" + response.dictList[j].dictID] = response.dictList[j].dictName;
                	}
					getProjectList();
				}
			});
		}
		getProjectDict();
		// 项目列表5个
		function getProjectList() {
			var postData = {
				"criteria/_entity" : "com.zhmy.xmgl.ZHMY_PROJECT.ZhmyProject",
				pageIndex: 1,
				pageSize:5
			};
			$.ajax({
				url: "<%=request.getContextPath() %>/com.zhmy.xmgl.zhmyprojectbiz.queryZhmyProjects.biz.ext",
				type:"post",
				data: postData,
				success:function(response){
					returnJson = response.zhmyprojects;
                	var str = '';
                	for(var i = 0;i < returnJson.length;i++){
                		var status = '';
                		status = projectDict["dict" +returnJson[i]['projectStatus']];
                		if ( status == undefined ) status = ''; 
                		if(i > 5){
                		return false;
                		}else{
	                		str += '<div class="log-i">';
	                		    str += '<p class="name">【项目标题】'+ returnJson[i]['projectName'] +'</p>';
	                			str += '<p class="content">' + beautySub(returnJson[i]['projectNote'] , 50)+ '</p>';
	                			str += '<p class="time">' +status+ '</p>';
	                		str += '</div>';
                		}
                	}
  					document.getElementById('project').innerHTML = str
				}
			});
		}
		  
		function refresh(type){
			switch (type) {
				case 'data':
					getCountProject();
					getCountJxProject();
					getCountBUG();
					break;
				case 'proList':
					getProjectList();
					break;
				case 'logList':
					getLogList();
					break;
				case 'bugList':
					getBUGlist();
					break;
			}
		}
		
		
		function getCountProject(){
			$.ajax({
	            url:"<%=request.getContextPath() %>/com.zhmy.xmgl.zhmyprojectbiz.countProject.biz.ext",
	            type:'POST',
	            data:json,
	            success:function(response){
	                var returnJson = response.cou[0].count_projectId;
	  				document.getElementById('countproject').innerHTML = returnJson
	                                     
	            }
	   		});
		}
		getCountProject()
		
		function getCountJxProject(){
			$.ajax({
	            url:"<%=request.getContextPath() %>/com.zhmy.xmgl.zhmyprojectbiz.countJxProject.biz.ext",
	            type:'POST',
	            data:json,
	            success:function(response){
	                var returnJson = response.cou[0].count_projectId;
	  				document.getElementById('countJxproject').innerHTML = returnJson;
	            }
	   		});
		}
		getCountJxProject();
		
		function getCountBUG(){
			$.ajax({                                
	            url:"<%=request.getContextPath() %>/com.zhmy.xmgl.bug.zhmybugbiz.countBugs.biz.ext",
	            type:'POST',
	            data:json,
	            success:function(response){
	                var returnJson = response.cou[0].count_bugId;
	  				document.getElementById('countbug').innerHTML = returnJson;
	            }
	   		});
		}
		getCountBUG()
		//bug列表
		function getBUGlist(){
			$.ajax({
	            url:"<%=request.getContextPath() %>/com.zhmy.xmgl.bug.zhmybugbiz.queryZhmyBugsForWelcome.biz.ext",
	            type:'POST',
	            data:json,
	            success:function(response){
	                var returnJson = response.zhmycount;      
	                var str = '';
  					for(var i = 0;i < returnJson.length;i++){
                		
                		if(i > 5){
                			return false;
                		}else{
	                		str += '<div class="log-i">';
	                		    str += '<p class="name">【Bug标题】'+ returnJson[i]['bugTitle'] +'</p>';
	                			str += '<p class="content">' + beautySub(returnJson[i]['bugContent'],50)+ '</p>';
	                			str += '<p class="time">' +returnJson[i]['bugCtime']+ '</p>';
	                		str += '</div>';
                		}
                			
                	}
                	document.getElementById('buglist').innerHTML = str
	                                     
	            }
	   		});
		}
		getBUGlist()
    </script>

</body>
</html>
